Draft
Conversation
fmassa
reviewed
Mar 5, 2026
|
|
||
| # _unsafe_view is not tagged as a view op but is semantically a reshape; | ||
| # its non-tensor shape args become invalid after sharding so skip costing. | ||
| if node.target == torch.ops.aten._unsafe_view.default: |
Contributor
There was a problem hiding this comment.
Shouldn't this be fixed in PyTorch? I'd expect _unsafe_view to have the is_view tag set?
Contributor
Author
There was a problem hiding this comment.
IIUC, this is intentional? this flag prevents AOTAutograd from doing all the view-replay needed for functionalization.
// NOTE [ Unsafe View ]
// _unsafe_view() differs from view() in that the returned tensor isn't treated
// as a view for the purposes of automatic differentiation. (It's not listed in
// VIEW_FUNCTIONS in gen_inplace_or_view_type.py). It's only safe to use if the
// `self` tensor is temporary. For example, the viewed tensor here (a + b) is
// discarded immediately after viewing:
//
// res = at::_unsafe_view(a + b, size);
//
// This is a hack because in-place operations on tensors treated like views
// can be much more expensive than the same operations on non-view tensors.
But I think for autoparallel you want the "is_view", 0-cost semantics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.